//
//  CommonAPI.m
//  ShopProject
//
//  Created by 小焘无量 on 2018/9/27.
//  Copyright © 2018年 ShopProject. All rights reserved.
//

#import "CommonAPI.h"

@implementation CommonAPI

+(BOOL)telPhoneCheck:(NSString *)tel {
    if (tel.length != 11) {
        return NO;
    }
    return YES;
}

+(BOOL)passwordCheck:(NSString *)password {
    if ((password.length < 6) || (password.length > 16)) {
        return NO;
    }
    return YES;
}

+(BOOL)StringIsNull:(NSString *)str {
    if ((str == nil) || (str == NULL)) {
        return YES;
    }
    if ([str isKindOfClass:[NSNull class]]) {
        return YES;
    }
    if (str.length == 0) {
        return YES;
    }
    if ([str isEqualToString:@""]) {
        return YES;
    }
    return NO;
}

+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size
{
    CGRect rect = CGRectMake(0, 0, size.width, size.height);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;
}

@end
